#include <iostream>
#include <vector>
#include <memory>

// 插件接口
class PluginInterface {
public:
    virtual void execute() = 0;
    virtual ~PluginInterface() {}
};

// 插件实现示例
class ConcretePluginA : public PluginInterface {
public:
    void execute() override {
        std::cout << "Executing Plugin A\n";
    }
};

class ConcretePluginB : public PluginInterface {
public:
    void execute() override {
        std::cout << "Executing Plugin B\n";
    }
};

// 插件管理器
class PluginManager {
    std::vector<std::unique_ptr<PluginInterface>> plugins;
public:
    void loadPlugin(std::unique_ptr<PluginInterface> plugin) {
        plugins.push_back(std::move(plugin));
    }

    void executeAll() {
        for (auto& plugin : plugins) {
            plugin->execute(); // 动态多态
        }
    }

    // 静态多态的示例可能需要更复杂的场景来展示，这里省略
};

int main() {
    PluginManager manager;
    manager.loadPlugin(std::make_unique<ConcretePluginA>());
    manager.loadPlugin(std::make_unique<ConcretePluginB>());

    manager.executeAll();

    return 0;
}